<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var arr = [7,8,3,6,7,48,9,7,57,99,4,51,8,59,79,46,1,46,7,9,6,5,46,4,48,78]
    for (i=0;arr.length - 1 > i;i++ ) {  //外层循环管趟数
        for (j = 0; arr.length-i-1 >= j;j++) { //内层循环管每趟交换的次数
            //内部交换两个变量得值
            if (arr[j] > arr[j+1]) {
                var temp = arr[j]
                arr[j] = arr[j+1]
                arr[j+1] = temp
            }
        }
    }
    console.log(arr);
</script>
</html>